import router from "@/router";
import { useUserInfoStore } from "../store/useStore"

export function loginOut(after?: () => void) {
    const UserInfo = useUserInfoStore()
    localStorage.removeItem("token")
    UserInfo.$reset()
    const AllRouter = router.getRoutes()
    AllRouter.forEach(item => {
        if (item.path != '/login' && item.name) {
            router.removeRoute(item.name);
        }
    })

    router.push("/login")
    after && after()
}

